package com.ddn.controller.person;

import com.ddn.model.personnel.Dept;
import com.ddn.model.personnel.Station;
import com.ddn.service.personnel.EmplService;
import com.ddn.service.personnel.StationService;
import com.ddn.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author Bikakaso
 * @date 2023/1/1
 * ddn_hotel
 */
@RestController
@RequestMapping("/station")
public class StationController {
    @Autowired
    private StationService stationService;

    // 下拉框
    @RequestMapping("/test")
    public ResultData test() {
        ResultData data = stationService.test();
        return data;
    }

    // 查询全部 && 模糊查询
    @RequestMapping("/list")
    public ResultData findAllDept(@RequestParam HashMap<String,Object> map) {
        ResultData data = stationService.findAll(map);
        return data;
    }
    @RequestMapping("/add")
    public ResultData addAllDept(@RequestParam HashMap<String,Object> map) {
        System.out.println("map ===== " + map);
        ResultData data = stationService.add(map);
        return data;
    }
    @RequestMapping("/delete")
    public ResultData deleteById(int id) {
        ResultData data = stationService.delete(id);
        return data;
    }
    @RequestMapping("/deleteBatch")
    public ResultData deleteBatch(int[] ids) {
        ResultData data = stationService.deleteBatch(ids);
        return data;
    }
    @RequestMapping("/edit")
    public ResultData edit(Station station) {
        ResultData data = stationService.edit(station);
        return data;
    }
    @RequestMapping("/edit2")
    public ResultData editDept2(@RequestParam HashMap<String,Object> map) {
        System.out.println("map = " + map);
        Integer ids = stationService.findId(map);
        System.out.println("id ====== " + ids);
        map.put("ids",ids);
//        System.out.println("map ============== " + map);
        ResultData data = stationService.edit2(map);
        return data;
    }


    // 下拉框数据回显
    @RequestMapping("/sname")
    public ResultData sname(int id) {
        System.out.println("id = " + id);
        ResultData data = stationService.select(id);
        return data;
    }
}
